//
//  HotAskDetailsViewController.m
//  SHHCPhone
//
//  Created by Sheng long on 14-9-21.
//  Copyright (c) 2014年 sheng long. All rights reserved.
//

#import "HotAskDetailsViewController.h"
#import "HotAskDetailsTableView.h"

@interface HotAskDetailsViewController ()
@end

@implementation HotAskDetailsViewController

@synthesize dataDic;

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    NSString *name = [NSString stringWithFormat:@"%@的提问",[[dataDic objectForKey:@"user"]valueForKey:@"nickname"]];
    [navigationBarView setTitle:name];
    [navigationBarView setNormalLeftButton];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self againLoading];
}

//重新加载数据
-(void)againLoading
{
    [self showProgressView:nil belowSubview:navigationBarView];
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1];
    [dic setValue:IOS_CONSULTDETAIL forKey:IOS_METHOD_NAME];
    [dic setValue:[dataDic valueForKey:@"id"] forKey:@"id"];
    
    ASIHTTPRequest *request =  [NetUtls httpGet:self withValue:dic tag:IOS_CONSULTDETAIL_TAG need:NO];
    [self.netArray addObject:request];
    [request startAsynchronous];
}

#pragma mark - ASIHTTPRequestDelegate
-(void)requestFinished:(ASIHTTPRequest *)request
{
    CLog(@"%@",[request responseString]);
    NSDictionary *dic = [[request responseString] objectFromJSONString];
    if (dic != nil) {
        [self hideProgressView];
        HotAskDetailsTableView *table = [[HotAskDetailsTableView alloc] initWithFrame:CGRectMake(0, NAVIGATIONBAR_HEIGHT, CURRENT_CONTENT_WIDTH, CURRENT_CONTENT_HEIGHT-NAVIGATIONBAR_HEIGHT)];
        [table setBackgroundColor:[UIColor whiteColor]];
        [self.view addSubview:table];
        table.dataDic = dic;
    }else{
        [self clickAgainLoadingView:0];
    }
}

-(void)requestFailed:(ASIHTTPRequest *)request
{
    [self clickAgainLoadingView:0];
}

@end
